package com.aionemu.gameserver.network.aion.serverpackets;

import com.aionemu.commons.database.dao.DAOManager;
import com.aionemu.gameserver.configs.main.SiegeConfig;
import com.aionemu.gameserver.dao.LegionDAO;
import com.aionemu.gameserver.model.legion.LegionEmblem;
import com.aionemu.gameserver.model.siege.SiegeLocation;
import com.aionemu.gameserver.model.siege.SiegeRace;
import com.aionemu.gameserver.network.aion.AionConnection;
import com.aionemu.gameserver.network.aion.AionServerPacket;
import com.aionemu.gameserver.services.SiegeService;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import javolution.util.FastMap;

public class SM_SIEGE_LOCATION_INFO extends AionServerPacket
{
  private int infoType;
  private Map<Integer, SiegeLocation> locations;

  public SM_SIEGE_LOCATION_INFO()
  {
    this.infoType = 0;
    this.locations = SiegeService.getInstance().getSiegeLocations();
  }

  public SM_SIEGE_LOCATION_INFO(SiegeLocation paramSiegeLocation)
  {
    this.infoType = 1;
    this.locations = new FastMap();
    this.locations.put(Integer.valueOf(paramSiegeLocation.getLocationId()), paramSiegeLocation);
  }

  protected void writeImpl(AionConnection paramAionConnection, ByteBuffer paramByteBuffer)
  {
    if (!SiegeConfig.SIEGE_ENABLED)
    {
      writeC(paramByteBuffer, 0);
      writeH(paramByteBuffer, 0);
      return;
    }
    writeC(paramByteBuffer, this.infoType);
    writeH(paramByteBuffer, this.locations.size());
    Iterator localIterator = this.locations.values().iterator();
    while (localIterator.hasNext())
    {
      SiegeLocation localSiegeLocation = (SiegeLocation)localIterator.next();
      writeD(paramByteBuffer, localSiegeLocation.getLocationId());
      int i = localSiegeLocation.getLegionId();
      writeD(paramByteBuffer, i);
      LegionEmblem localLegionEmblem = ((LegionDAO)DAOManager.getDAO(LegionDAO.class)).loadLegionEmblem(i);
      int j = localLegionEmblem.getEmblemId();
      writeD(paramByteBuffer, j);
      writeC(paramByteBuffer, 0x00);//255
      writeC(paramByteBuffer, localLegionEmblem.getColor_r());
      writeC(paramByteBuffer, localLegionEmblem.getColor_g());
      writeC(paramByteBuffer, localLegionEmblem.getColor_b());
      writeC(paramByteBuffer, localSiegeLocation.getRace().getRaceId());
      writeC(paramByteBuffer, localSiegeLocation.isVulnerable() ? 2 : 0);
      writeC(paramByteBuffer, 1); //localSiegeLocation.isCanTeleport() ? 1 : 0);
      writeC(paramByteBuffer, localSiegeLocation.getNextState());
      writeD(paramByteBuffer, 0);
      writeD(paramByteBuffer, 0);
    }
  }
}

/* Location:           I:\Aion-Engine-Public-Last Version\GameServer\ae-game-1.0.1.jar
 * Qualified Name:     com.aionemu.gameserver.network.aion.serverpackets.SM_SIEGE_LOCATION_INFO
 * JD-Core Version:    0.6.0
 */
